import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import { setupStore } from "~/store";
import { setupI18n } from "~/locales";

import {
  setupAntd,
  setupAssets,
  setupCustomComponents,
  setupDirectives,
  setupGlobalMethods,
} from "~/plugins";

const app = createApp(App);

function setupPlugins() {
  // 注册全局常用的ant-design-vue组件
  setupAntd(app);
  // 引入静态资源
  setupAssets();
  // 注册全局自定义组件,如：<svg-icon />
  setupCustomComponents(app);
  // 注册全局自定义指令，如：v-permission权限指令
  setupDirectives(app);
  // 注册全局方法，如：app.config.globalProperties.$message = message
  setupGlobalMethods(app);
}

async function setupApp() {
  setupStore(app);
  await setupI18n(app);
  await app.use(router);
  app.mount("#app");
}

setupPlugins();
setupApp();
